CAMEL-24634: Authorize with camel-opa in the camel-spiffe example - #264
Open
oscerd wants to merge 1 commit into
Open
CAMEL-24634: Authorize with camel-opa in the camel-spiffe example#264oscerd wants to merge 1 commit into
oscerd wants to merge 1 commit into
Conversation
SPIFFE keeps authenticating the callers; Open Policy Agent now decides what an authenticated caller may do. The shared workload identity policy sends the SPIFFE ID of the caller and the route id to OPA, the allow-lists move from application.properties to Rego policies with their own tests, and Compose gains an OPA server that reloads the policies when they change. A policy that cannot be evaluated is answered with HTTP 503.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
camel-opa(CAMEL-24634) to thespiffeexample: SPIFFE keeps authenticating the callers, Open Policy Agent now decides what an authenticated caller may do.WorkloadIdentityPolicyroute configuration validates the JWT-SVID as before, then callsopa:camel/spiffe/<service>/allowwithincludeHeaders=CamelSpiffeSpiffeId,X-On-Behalf-Of, so OPA only sees the SPIFFE ID of the caller (and, on the second hop, on whose behalf it calls) plus the route id. The token never leaves the application. TheCamelOpaDecisionAllowheader drives the 403, and anOpaPolicyEvaluationExceptionbecomes a 503: the policy fails closed.application.propertiesto Rego:opa/backend.rego(who may callordersandaudit) andopa/inventory.rego(the backend only, and only on behalf of a caller who may read the orders, by referring to the backend's permissions in the same OPA).opa/policy_test.regoholds 10 Rego unit tests, run withopa test.opaservice (openpolicyagent/opa:1.9.0-static, policies bind-mounted,--watchso edits reload, console decision logs, port 8181 published). The README shows how to ask OPA directly, read its decision log, and change who may do what by editing the Rego file without rebuilding anything.AllowListis removed; the tests bind a mockedOPAClient(autowired by the component, like the SPIFFE client) that decides like the Rego policies and lets the tests check the input document sent to OPA.Notes
camel-bomdoes not manage Jackson, so the example importsjackson-bomat${jackson2-version}. Without it the mix ofjackson-databind2.22 andjackson-annotations2.17 fails at runtime.zflag so that it works on SELinux hosts.Verification
18 unit tests and 10 Rego tests pass, Apache RAT passes, and the stack was run end to end: 200/403 matrix from OPA decisions, the inventory delegation rule, the decision log showing only the SPIFFE ID and the route id, and a direct query to OPA.